package com.xh3140.android.widget.common;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;

import androidx.annotation.ColorInt;
import androidx.annotation.IntRange;
import androidx.annotation.Px;

/**
 * 线性分割条
 * 用于设置线性布局的分割线
 *
 * @see android.widget.LinearLayout#setDividerDrawable(Drawable)
 * @see androidx.appcompat.widget.LinearLayoutCompat#setDividerDrawable(Drawable)
 */
public class DividerDrawable extends GradientDrawable {
    /**
     * @param color     分割线颜色,argb
     * @param thickness 分割线粗细程度,px
     */
    public DividerDrawable(@ColorInt int color, @Px int thickness) {
        setShape(RECTANGLE);
        setColor(color);
        setSize(thickness, thickness);
    }

    /**
     * @param color     分割线颜色,argb
     * @param alpha     透明度(0~255)
     * @param thickness 分割线粗细程度,px
     */
    public DividerDrawable(@ColorInt int color, @IntRange(from = 0, to = 255) int alpha, @Px int thickness) {
        setShape(RECTANGLE);
        setColor(color);
        setAlpha(alpha);
        setSize(thickness, thickness);
    }
}
